
#include"gamewidget.h"

gamewidget::gamewidget(QWidget *parent)
    : QWidget{parent}
{
    this->parent=parent;//将父窗口传入
    this->setFixedSize(1800,1015);//设置窗口大小
    this->setWindowTitle("捕鱼达人");//设置标题
    this->setWindowIcon(QIcon("img/icon"));//设置应用图标
    this->setAutoFillBackground(true);//使得子窗口盖过主窗口

    //创建背景
    QPalette palette;
    palette.setBrush(QPalette::Window,QBrush(QPixmap("img/background2")));
    this->setPalette(palette);


    //创建按钮


    //简单模式按钮
    easy=new QPushButton(this);
    easy->setIcon(QIcon("img/easy"));
    easy->setIconSize(QSize(400,135));
    easy->setFlat(true);
    easy->move(this->width()/2-200,this->height()/3-40);
//    this->setFocusPolicy(Qt::NoFocus);


      //困难模式按钮
    hard=new QPushButton(this);
    hard->setIcon(QIcon("img/hard"));
    hard->setIconSize(QSize(400,135));
    hard->setFlat(true);
    hard->move(this->width()/2-200,this->height()/3*2-150);
//    this->setFocusPolicy(Qt::NoFocus);


    //返回按钮
    back=new QPushButton(this);
    back->setIcon(QIcon("img/back"));
    back->setIconSize(QSize(400,135));
    back->setFlat(true);
    back->move(this->width()/2-200,this->height()-250);
//    this->setFocusPolicy(Qt::NoFocus);

    //实现信号连接
    this->connect(back,SIGNAL(clicked()),this,SLOT(clickback()));
    this->connect(easy,SIGNAL(clicked()),this,SLOT(clickeasy()));
    this->connect(hard,SIGNAL(clicked()),this,SLOT(clickhard()));
}


//给槽函数具体定义
void gamewidget::clickeasy()//easy键的槽函数
{
    easyview=new Easyview;
    easyview->show();
    parent->hide();
}


void gamewidget::clickhard()//hard键的槽函数
{
    hardview=new Hardview;
    hardview->show();
    parent->hide();
}


void gamewidget::clickback()//back键的槽函数
{
    this->hide();
}
